import 'package:common/base/base_state.dart';
import 'package:common/base/base_stateful_widget.dart';
import 'package:flutter/material.dart';

import 'main_page_body.dart';
import 'main_page_bottom_bar.dart';

///https://blog.csdn.net/zzz777qqq/article/details/128506308
class MainPage extends BaseStatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends BaseState<MainPage> {
  late MainPageBody _mainBody;

  @override
  void onStateInit() {
  }

  @override
  bool onNeedAppBar() {
    return false;
  }

  @override
  bool onNeedBack() {
    return false;
  }

  @override
  Widget onBodyCreate() {
    _mainBody = MainPageBody();
    return _mainBody.createBody(context);
  }

  @override
  Widget? onBottomBarCreate() {
    MainPageBottomBar bottomBarCreate = MainPageBottomBar(onButtonPressed: (int value) {
      _mainBody.pageController.jumpToPage(value);
    });
    return bottomBarCreate.createBottomBar();
  }

  @override
  bool onNeedRequestPermission() {
    return true;
  }
}
